﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Main.Master" AutoEventWireup="true" CodeBehind="TableAllocation.aspx.cs" Inherits="RestaurantManagerWebApp.Pages.TableManagement.TableAllocation" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style26 {
            font-size: medium;
        }
        .auto-style24 {
            font-size: medium;
        }
        .auto-style29 {
            font-size: medium;
        }
        .auto-style30 {
            font-size: medium;
        }
        .auto-style31 {
            font-size: medium;
        }
        .auto-style34 {
            width: 286px;
        }
        .auto-style35 {
            font-size: medium;
            width: 286px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="auto-style3">
        <tr>
            <td class="auto-style26">
            <asp:Label ID="Label6" runat="server" Text="Table Management Menu"></asp:Label>
            </td>
            <td><span class="auto-style26"></td>
            <td class="auto-style34"></td>
            <td></span></td>
        </tr>
        <tr>
            <td class="auto-style26">
            <asp:Button ID="buttonManageTables" runat="server" OnClick="buttonManageTables_Click" Text="Manage Tables" CssClass="auto-style26" />
            </td>
            <td class="auto-style27">
            <asp:Button ID="buttonAllocateTables" runat="server" OnClick="buttonAllocateTables_Click" Text="Allocate Tables" style="margin-left: 0px" CssClass="auto-style26" />
            </td>
            <td class="auto-style35">&nbsp;</td>
            <td>
            <asp:Button ID="buttonReturn" runat="server" OnClick="buttonReturn_Click" Text="Return to Main Table Management" Width="269px" CssClass="auto-style26" />
            </td>
        </tr>
        </table>
    <br />
    <table class="auto-style3">
        <tr>
            <td>
                <asp:Image ID="Image1" runat="server" Height="480px" ImageUrl="~/Images/restaurantTableLayout.JPG" Width="680px" />
            </td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="font-size: medium">
            </td>
            <td></td>
        </tr>
    </table>
    <br />
    <table class="auto-style3">
        <tr>
            <td class="auto-style24">&nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style24">
    <asp:Label ID="labelStatus" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="auto-style24">
    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" ShowFooter ="True" Height="162px" Width="600px" AutoGenerateColumns="False" DataKeyNames="table_no" 
        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" style="margin-right: 36px">
        <Columns>
            <asp:TemplateField HeaderText="Table No" SortExpression="table_no">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("table_no") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("table_no") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" Width="18px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Availability" SortExpression="status">
                <EditItemTemplate>
                    <asp:Label ID="lblAvailability" runat="server" Text='<%# Bind("status") %>' Visible="false"></asp:Label>
                    <asp:DropDownList ID="ddlEditStatus" runat="server" Text='<%# Bind("status") %>'>
                        <asp:ListItem Value="Available">Available</asp:ListItem>
                        <asp:ListItem Value="Occupied">Occupied</asp:ListItem>
                        <asp:ListItem Value="Reserved">Reserved</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("status") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" Width="30px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Capacity" SortExpression="capacity">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("capacity") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("capacity") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" Width="25px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Deletion">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" 
                 CommandArgument='<%# Eval("table_no") %>' 
                 CommandName="Delete" runat="server">
                 Delete</asp:LinkButton>
            </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle Width="25px" HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Update" ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="True" CommandArgument='<%# Eval("table_no") %>'  CommandName="Update" Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle Width="25px" HorizontalAlign="Center" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT table_no, status, capacity FROM Tables WHERE (status &lt;&gt; 'NIL') ORDER BY table_no" 
                DeleteCommand="DELETE FROM [Tables] WHERE [table_no] = @table_no" 
                InsertCommand="INSERT INTO [Tables] ([table_no], [status], [capacity]) VALUES (@table_no, @status, @capacity)" 
                UpdateCommand="UPDATE [Tables] SET [status] = @status, [capacity] = @capacity WHERE [table_no] = @table_no">
                <DeleteParameters>
                  <asp:Parameter Name="table_no" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="table_no" Type="String" />
                    <asp:Parameter Name="status" Type="String" />
                    <asp:Parameter Name="capacity" Type="Decimal" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="status" Type="String" />
                    <asp:Parameter Name="capacity" Type="Decimal" />
                    <asp:Parameter Name="table_no" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <br />
    <table class="auto-style3">
        <tr>
            <td class="auto-style29">
            <asp:Button ID="buttonNewTable" runat="server" OnClick="Button1_Click" Text="Add New Tables" CommandName="buttonNewTable" />
            &nbsp;&nbsp;&nbsp;
            <asp:DropDownList ID="ddlNewTables" runat="server" OnSelectedIndexChanged="ddlNewTables_SelectedIndexChanged" AutoPostBack ="true">
                <asp:ListItem Value="0">0</asp:ListItem>
                <asp:ListItem Value="1">1</asp:ListItem>
                <asp:ListItem Value="2">2</asp:ListItem>
                <asp:ListItem Value="3">3</asp:ListItem>
                <asp:ListItem Value="4">4</asp:ListItem>
                <asp:ListItem Value="5">5</asp:ListItem>
                <asp:ListItem Value="6">6</asp:ListItem>
                <asp:ListItem Value="7">7</asp:ListItem>
                <asp:ListItem Value="8">8</asp:ListItem>
                <asp:ListItem Value="9">9</asp:ListItem>
                <asp:ListItem Value="10">10</asp:ListItem>
                <asp:ListItem Value="11">11</asp:ListItem>
                <asp:ListItem Value="12">12</asp:ListItem>
                <asp:ListItem Value="13">13</asp:ListItem>
                <asp:ListItem Value="14">14</asp:ListItem>
                <asp:ListItem Value="15">15</asp:ListItem>
                <asp:ListItem Value="16">16</asp:ListItem>
                <asp:ListItem Value="17">17</asp:ListItem>
                <asp:ListItem Value="18">18</asp:ListItem>
                <asp:ListItem Value="19">19</asp:ListItem>
                <asp:ListItem Value="20">20</asp:ListItem>
                <asp:ListItem Value="21">21</asp:ListItem>
                <asp:ListItem Value="22">22</asp:ListItem>
                <asp:ListItem Value="23">23</asp:ListItem>
                <asp:ListItem Value="24">24</asp:ListItem>
                <asp:ListItem Value="25">25</asp:ListItem>
                <asp:ListItem Value="26">26</asp:ListItem>
                <asp:ListItem Value="27">27</asp:ListItem>
                <asp:ListItem Value="28">28</asp:ListItem>
                <asp:ListItem Value="29">29</asp:ListItem>
                <asp:ListItem Value="30">30</asp:ListItem>
            </asp:DropDownList>
            </td>
            <td class="auto-style30">&nbsp;</td>
            <td class="auto-style31">&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style29">
                <span class="auto-style26">
            <asp:Label ID="Label3" runat="server" Text="Table No" Visible="False"></asp:Label>
            </td>
            <td class="auto-style30">
            <asp:Label ID="Label4" runat="server" Text="Availability" Visible="False"></asp:Label>
                </span>
            </td>
            <td class="auto-style31">
            <asp:Label ID="Label5" runat="server" Text="Capacity" Visible="False"></asp:Label>
            </td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style29">
            <asp:PlaceHolder ID="autoGenTextbox" runat="server"></asp:PlaceHolder>
            </td>
            <td class="auto-style30">
            <asp:PlaceHolder ID="autoGenTextbox0" runat="server"></asp:PlaceHolder>
            </td>
            <td class="auto-style31">
            <asp:PlaceHolder ID="autoGenTextbox1" runat="server"></asp:PlaceHolder>
            </td>
            <td>&nbsp;</td>
        </tr>
    </table>
<br />
</asp:Content>
